/*
 * =====================================================================================
 *
 *       Filename:  xs_common_stuff.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  26/03/13 15:48:28
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Tsihang (), isoledadcache@gmail.com
 *        COMPANY:  SGCHIP
 *
 * =====================================================================================
 */
#include <stdio.h>
#include <string.h>
#include <time.h>

extern int g_timezone ;

int xs_get_local_time(int *xs_year, 
                int *xs_month, 
                  int *xs_day, 
                    int *xs_hour, 
                      int *xs_minute, 
                       int *xs_second)
{
    time_t timep;
    struct tm tm;

    time(&timep);
    //printf("%s%ju secs since the Epoch\n", asctime(localtime(&result)), (uintmax_t)result);
    /* convert to current timezone */
    timep += g_timezone * 60 *60;
    gmtime_r(&timep, &tm);

    *xs_year = tm.tm_year + 1900;
    *xs_month = tm.tm_mon+1;
    *xs_month = tm.tm_mday;

    *xs_hour = tm.tm_hour;
    *xs_minute = tm.tm_min;
    *xs_second = tm.tm_sec;

    return 0;
}
